package cn.com.action;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.opensymphony.xwork2.ActionSupport;

import cn.com.biz.PexaminationPackageBiz;
import cn.com.entity.PexaminationPackage;

public class PexaminationPackageAction extends ActionSupport implements Serializable,SessionAware {
	private Map<String, Object> session;
	private PexaminationPackageBiz pexaminationpackagebiz;
	private PexaminationPackage pexaminationpackage;
	
	
	public Map<String, Object> getSession() {
		return session;
	}
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
	public PexaminationPackageBiz getPexaminationpackagebiz() {
		return pexaminationpackagebiz;
	}
	public void setPexaminationpackagebiz(
			PexaminationPackageBiz pexaminationpackagebiz) {
		this.pexaminationpackagebiz = pexaminationpackagebiz;
	}
	public PexaminationPackage getPexaminationpackage() {
		return pexaminationpackage;
	}
	public void setPexaminationpackage(PexaminationPackage pexaminationpackage) {
		this.pexaminationpackage = pexaminationpackage;
	}
	//查询所有套餐
	public String selectAllPexaminationPackage(){
		ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		pexaminationpackagebiz=(PexaminationPackageBiz)ctx.getBean("pexaminationpackagebiz");
		List<PexaminationPackage> list=pexaminationpackagebiz.selectAllPexaminationPackage();
		if(list!=null){
			session.put("list", list);
		}
		return SUCCESS;
	}
	//通过id查询的action
	public String selectPexaminationPackageByid(){
		ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		pexaminationpackagebiz=(PexaminationPackageBiz)ctx.getBean("pexaminationpackagebiz");
		PexaminationPackage pexaminationPackagebyid=pexaminationpackagebiz.selectPexaminationPackageByid(pexaminationpackage);
		if(pexaminationPackagebyid!=null){
			session.put("pexaminationPackagebyid", pexaminationPackagebyid);
		}
		return SUCCESS;
	}
	//增加套餐
	public String addPexaminationPackage(){
		boolean bool=false;
		ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		pexaminationpackagebiz=(PexaminationPackageBiz)ctx.getBean("pexaminationpackagebiz");
		boolean b=pexaminationpackagebiz.addPexaminationPackage(pexaminationpackage);
		if(b){
			bool=true;
			return SUCCESS;
		}else{
			return ERROR;
		}
		
	}
	//删除套餐
	public String deletePexaminationPackage(){
		boolean bool=false;
		ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		pexaminationpackagebiz=(PexaminationPackageBiz)ctx.getBean("pexaminationpackagebiz");
		boolean b=pexaminationpackagebiz.deletePexaminationPackage(pexaminationpackage);
		if(b){
			bool=true;
			return SUCCESS;
		}else{
			return ERROR;
		}
	}
	//修改套餐
	public String updatePexaminationPackage(){
		boolean bool=false;
		ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		pexaminationpackagebiz=(PexaminationPackageBiz)ctx.getBean("pexaminationpackagebiz");
		boolean b=pexaminationpackagebiz.updatePexaminationPackage(pexaminationpackage);
		if(b){
			bool=true;
			return SUCCESS;
		}else{
			return ERROR;
		}
	}

}
